#ifndef __PUBLIC_H__
#define __PUBLIC_H__

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>

#define	RET_ERR		(-1)
#define	RET_OK		(0)
#define	RET_AGAIN	(-2)


#ifdef WIN32
#include <winsock2.h>
#include <windows.h>

typedef	DWORD			pid_t;
typedef HANDLE			pthread_t;
typedef	CRITICAL_SECTION	pthread_mutex_t;
typedef HANDLE			pthread_cond_t;


#define	vsnprintf		_vsnprintf
#define	getpid			GetCurrentProcessId
#define	pthread_self		GetCurrentThreadId
#define	pthread_mutex_init(a,b)	InitializeCriticalSection(a)
#define pthread_mutex_destory	DeleteCriticalSection
#define pthread_mutex_lock	EnterCriticalSection
#define pthread_mutex_unlock	LeaveCriticalSection


#else
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/select.h>
#include <pthread.h>



#endif

extern	pid_t           g_cur_pid;
extern	time_t          g_cur_time;


#ifdef __cplusplus
extern "C" {
#endif

int     time_fmt( time_t t, char *buf );

#ifdef WIN32

int	pthread_cond_init( pthread_cond_t *cond, const pthread_condattr_t *attr );
int	pthread_cond_destroy( pthread_cond_t *cond );
int	pthread_cond_wait( pthread_cond_t *cond, pthread_mutex_t *mutex );
int	pthread_cond_signal( pthread_cond_t *cond );


#else


#endif
#ifdef __cplusplus
} /* end of extern "C" */
#endif



#endif
